home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 500 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  64 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: aishdas@haven.ios.com (Micha Berger)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: #ifdef XXXX
  5. Date: 15 Feb 1996 15:42:52 GMT
  6. Organization: AishDas Society
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4fv9er$aeq@news.ios.com>
  9. References: <1996Feb1.092058.4745@iiasa.ac.at> <9602020740.22411@mulga.cs.mu.OZ.AU> <9602141406.AA16760@sparc5.ferndown.ate.slb.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Content-Type: text
  12. X-Nntp-Posting-Host: haven.ios.com
  13. X-Newsreader: TIN [version 1.2 PL2]
  14. Content-Length: 1059
  15. X-Lines: 41
  16. Originator: clamage@taumet
  17.  
  18. devitto@ferndown.ate.slb.com wrote:
  19. : What about Bjarne's idea of "include" as a keyword that only has the effect
  20. : of a #include if the file has not been "include"d already.
  21.  
  22. I'm okay with it as long as we leave something to mean the old
  23. include-no-matter-what behavior.
  24.  
  25. A common trick for making an array that includes pointers to functions is
  26. something like:
  27.  
  28. file1.h --------
  29.  
  30. func(foo);
  31. func(bar);
  32.  
  33.  
  34.  
  35. file2.cc ------
  36.  
  37. #define func(x)        int x(char*);
  38. #include <file1.h>
  39. #undef func
  40. #define func(x)        { ##x, x },
  41.  
  42. struct funcHandle {
  43.     const char* const          name;
  44.     const int (* const)(char*) function;
  45. } funcArray[] = {
  46. #include <file1.h>
  47. };
  48.  
  49. --------------
  50.  
  51. It may be overly clever, but I've seen this one in almost every C/C++ shop
  52. I've worked in.
  53.  
  54. --
  55. Micha Berger 201 916-0287        Help free Ron Arad, held by Syria 3255 days!
  56. AishDas@haven.ios.com                     (16-Oct-86 -  5-Oct-95)
  57. <a href=news:alt.religion.aishdas>Orthodox Judaism: Torah, Avodah, Chessed</a>
  58. <a href=http://haven.ios.com/~aishdas>AishDas Society's Home Page</a>
  59.  
  60. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  61.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy is
  62.   summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  63. ]
  64.